package com.zw.pdm.module.craft.controller;

import com.zw.pdm.base.BaseController;
import com.zw.pdm.common.JsonResult;
import com.zw.pdm.entity.craft.CraGant;
import com.zw.pdm.entity.designtask.DsnGant;
import com.zw.pdm.module.basic.service.DictCommonService;
import com.zw.pdm.module.craft.model.ComprehensiveQueryModel;
import com.zw.pdm.module.craft.service.*;
import com.zw.pdm.module.designtask.model.DsnGantWorkModel;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

import static com.zw.pdm.constant.Constant.GROUP_SPECTYPE;

/**
 * @Description: 计划查询接口
 * @Author: China.sgl
 * @Date: 2020/8/3 16:11
 */
@Controller
@RequestMapping("/craft/EmployeeQuery")
@SuppressWarnings("all")
public class EmployeeQueryController extends BaseController {

    @Autowired
    private CraftReceiveService craftReceiveService;
    @Autowired
    private DictCommonService dictCommonService;
    @Autowired
    private CraftReleaseService craftReleaseService;
    @Autowired
    private CraftMaintainService craftMaintainService;
    @Autowired
    private EmployeeQueryService employeeQueryService;

    @GetMapping
    @RequiresPermissions({"tec:employee:view"})
    public String page(Model model) {
//        model.addAttribute("specialId", dictCommonService.findDictByGroupName(GROUP_SPECTYPE));
//        model.addAttribute("deptName", craftReleaseService.findCraftSectionByDeptId(4));
//        return "craft/employee/query";
        return "craft/employee/gantQuery";
    }

    /**
     * 接收列表
     */
    @ResponseBody
    @PostMapping("/query")
//    @RequiresPermissions({"report:query:view"})
    public JsonResult list(ComprehensiveQueryModel comprehensiveQueryModel) {
        startPage();
        List<ComprehensiveQueryModel> list = employeeQueryService.selectPro(comprehensiveQueryModel);
        return jsonResult(list);
    }
    /**
     * 根据条件查询员工业绩
     *
     * @param dsnGant
     * @return
     */
    @ResponseBody
    @PostMapping("/gantWork")
//    @RequiresPermissions({"dsn:employee:view"})
    public JsonResult findTaskerWorkByQuery(CraGant craGant) {
        startPage();
        List<DsnGantWorkModel> list = employeeQueryService.findTaskerWorkByQuery(craGant);
        return jsonResult(list);
    }
    /**
     * 项目任务项查看
     *
     * @param dsnGant
     * @return
     */
    @ResponseBody
    @PostMapping("/gantWorkDetail")
//    @RequiresPermissions({"dsn:employee:view"})
    public JsonResult findTaskerWorkDetailByQuery(CraGant craGant) {
        startPage();
        List<CraGant> list = employeeQueryService.findDsnGantByQuery(craGant);
        return jsonResult(list);
    }
}
